<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>对自己狠点</title>
  <style>
    ul {
      list-style-type: none;
    }

    li {
      float: left;
      margin-left: 10px;
    }

    img {
      width: 200px;
      height: 180px;
    }

    input {
      margin-left: 30%;
    }
  </style>
  <script>
    //$永远都是24k纯帅的十八岁的杨哥$
  </script>
</head>
<body>
<ul>
  <li><img src="images/ly.jpg" alt=""><br/><input type="button" value="赞(1)"></li>
  <li><img src="images/lyml.jpg" alt=""><br/><input type="button" value="赞(1)"></li>
  <li><img src="images/fj.jpg" alt=""><br/><input type="button" value="赞(1)"></li>
  <li><img src="images/bd.jpg" alt=""><br/><input type="button" value="赞(1)"></li>
</ul>
<script>


  //1.闭包
  //获取所有的按钮

  function my$(tagName) {
    return document.getElementsByTagName(tagName);
  }
  //获取的是所有的按钮
  var btnObjs=my$("input");
  //形成闭包了
  function ff() {
    var value=2;
    return function () {
      this.value="赞("+(value++)+")";
    }
  }
  for(var i=0;i<btnObjs.length;i++){
    //每个按钮都执行了一次ff()函数;
    btnObjs[i].onclick=ff();
  }


</script>
</body>
</html>